﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="Problem36.cs" company="Microsoft">
//   Copyright (c) Microsoft Corporation.  All rights reserved. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// </copyright>
// <summary>
//   Defines the Problem36 type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace EulerProblemsCSharp.Problems
{
    using System.Linq;

    /// <summary>
    /// Problem 36.
    /// </summary>
    public class Problem36 : ProblemBase
    {
        /// <summary>
        /// Gets Number.
        /// </summary>
        /// <value>
        /// The number.
        /// </value>
        public override int Number
        {
            get
            {
                return 36;
            }
        }

        /// <summary>
        /// Gets Description.
        /// </summary>
        /// <value>
        /// The description.
        /// </value>
        public override string Description
        {
            get
            {
                return "Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.";
            }
        }

        /// <summary>
        /// Solves problem 36.
        /// </summary>
        /// <returns>
        /// The solution to the problem.
        /// </returns>
        public override object Solve()
        {
            var query = from number in Enumerable.Range(1, 999999)
                        where number.IsPalindrome()
                        where number.IsPalindromeInBase2()
                        select number;

            var answer = query.Sum();

            return answer;
        }
    }
}